package numJewelsInStones;

import java.util.HashMap;
import java.util.Map;

public class Solution {
    public int numJewelsInStones(String jewels, String stones) {
        Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i < jewels.length(); i++) {
            map.put(jewels.charAt(i),0);
        }
        for (int i = 0; i < stones.length(); i++) {
            int t = map.getOrDefault(stones.charAt(i),-1);
            if(t!=-1) {
                map.put(stones.charAt(i),t+1);
            }
        }
        int ans = 0;
        for (int v: map.values()) {
            ans+=v;
        }
        return ans;
    }
}
